package com.ruoyi.repayment.mapper;


import com.ruoyi.repayment.pojo.Loan;
import com.ruoyi.repayment.pojo.LoanApplyfor;
import com.ruoyi.repayment.pojo.Product;
import com.ruoyi.repayment.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
@Mapper
public interface LoanMapper{
//    @Select(value = "select id, uid, repayment, product_id, loansprice, repaidprice from loan_applyfor")
//    List<LoanApplyfor> findByList();
    @Select(value = "select a.id,a.repayment,a.uid,a.product_id,a.loansprice,a.repaidprice,p.periods,p.interestRate,p.maxquota,p.periods from loan_applyfor a left join loan_product p on p.id=a.product_id")
    List<LoanApplyfor> findByLists();
    @Select(value = "select a.id,a.repayment,a.uid,a.product_id,a.loansprice,a.repaidprice,p.periods,p.interestRate,p.* from loan_applyfor a left join loan_product p on p.id=a.product_id where product_id=#{productId}")
    Product findByList(Integer productId);
    @Select(value = "select * from loan_user where id=#{userId}")
    User loginUser(Long userId);

    @Select(value = "select * from loan_product where product_id=#{productId}")
    Product findProductId(Long productId);

    @Select(value = "select * from loan_product where product_id=#{productId} and uid=#{userId}")
    Loan findLoanId(Long productId, Integer userId);

    List<Loan> loanList();
}
